// pages/detail/user-order-detail-page.js
const app = getApp()
import { RequestManager } from '../../util/requestManager.js'
let requestManager = new RequestManager()

Page({
  /**
   * 页面的初始数据
   */
  data: {
    isPhoneX:false,
    orderDetail:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let orderDetail = JSON.parse(options.orderDetail);
    this.setData({
      isPhoneX: app.globalData.isIphoneX,
      orderDetail:orderDetail
    })
  },

  action_cancel:function(){
    requestManager.cancelOrder(app.globalData.openid,this.data.orderDetail.id,result=>{
      wx.showToast({
        title: '取消订单成功',
        icon:'success',
        duration: 1500,
        success:function(){
          app.globalData.needReload = true;
          wx.navigateBack({
            delta: 1
          })
        }
      })
    })
  }
})